import {Injectable} from '@angular/core';
import {DataService} from './data.service';
import {PythonService} from './python.service';
declare function i(m);

@Injectable({
  providedIn: 'root'
})
export class ControlService {

  public eventRoutes:any;
  constructor(private ds: DataService,
              private ps: PythonService) {
    this.eventRoutes = {
      'k.p.send':() => {
        i(ds);
        i(ds.getData('k.p.ip'));
      },


    };
  }

  public call(methodId:string):void {
    i('[controlService] call() method is: '+methodId);
    try {
      this.eventRoutes[methodId]();
    } catch (e) {
      i(e);
    }

  }
}
